//
//  HOReportListTabelViewCellTableViewCell.m
//  微度报修
//
//  Created by foguo-mac-1 on 6/9/16.
//  Copyright © 2016 WeiDu. All rights reserved.
//

#import "HOReportListTableViewCell.h"
#import "UIImageView+WebCache.h"
#import "HOUtils.h"

@interface HOReportListTableViewCell()
@property(nonatomic, retain)HOReportOrderEntity *entity;
@end

@implementation HOReportListTableViewCell
- (void)awakeFromNib {
	// Initialization code
	[super awakeFromNib];
	self.contentView.autoresizesSubviews = YES;
	self.headerImgView.contentMode = UIViewContentModeScaleAspectFill;
	[self.headerImgView.layer setMasksToBounds:YES];
//	self.contentLbl.layer.borderWidth = 1;
	self.contentLbl.numberOfLines = 2;
	self.titleLbl.textColor = TEXT_COLOR_666666;
	self.departmentLbl.textColor = TEXT_COLOR_666666;
	self.contentLbl.font = [UIFont systemFontOfSize:15];
	self.departmentLbl.font = [UIFont systemFontOfSize:12];
	self.contentLbl.textColor = [UIColor blackColor];
	self.contentLbl.font = [UIFont boldSystemFontOfSize:13];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
- (void)setReportEntity:(HOReportOrderEntity *)entity
{
	self.entity = entity;
	NSURL *imgURL = [NSURL URLWithString:[HOUtils getValideString:entity.image]];
	[self.headerImgView sd_setImageWithURL:imgURL placeholderImage:[UIImage imageNamed:@"morentu"]];
	self.titleLbl.text =[NSString stringWithFormat:@"单号:%d", entity.orderSN];
	self.departmentLbl.text = entity.address;
	self.timeLbl.text = [HOUtils getDateFromTimeInterval:entity.createTime * 1000];
	
	self.assistantIndicateImgView.hidden = !entity.isAssistantReport;
	NSString *detail = [HOUtils getValideString:self.entity.detail];
	NSString *content = [NSString stringWithFormat:@"%@", entity.detail];
	if([detail isEqualToString:@"无"])
	{
		BOOL isPictureDetail = (self.entity.image && self.entity.image.length > 0 );
		BOOL isAudioDetail = (self.entity.voice && self.entity.voice.length > 0);
		if(isPictureDetail && isAudioDetail)
		{
			content = [NSString stringWithFormat:@"%@", @"[图片] + [语音]"];
		}
		else if(isPictureDetail)
		{
			content = [NSString stringWithFormat:@"%@", @"[图片]"];
		}
		else if(isAudioDetail)
		{
			content = [NSString stringWithFormat:@"%@", @"[语音]"];
		}
	}
	self.statusLbl.text = [entity getStatusStr];
	self.statusLbl.textColor = [HOUtils getOrderColorWithStatus:entity.status];
	self.contentLbl.text = content;
}

- (void)dealloc
{
	self.entity = nil;
	[super dealloc];
}

@end
